package ru.mera.aaclog.db;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * @version 1.0 3/03/2013
 * @author anavdeev
 */
@Entity
@Table(name="messages_xml")
@NamedQueries( {
    @NamedQuery(name = MessageXmlBody.GET_BY_MSG, 
                query = "SELECT mx FROM MessageXmlBody AS mx WHERE mx.message = ?1")
} )
public class MessageXmlBody implements Serializable {

    public static final String GET_BY_MSG = "getMsgXml";

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "mxml_id")
    private int id;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "mxml_mess", nullable = false)
    private MessageHeader message;
    
    @Column(name = "mxml_value", length=4096)
    private String value;

    public MessageXmlBody() {
        // Serializable ctor
    }
    
    public MessageXmlBody(Integer id) {
        this.id = id;
    }
    
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public MessageHeader getMessage() {
        return message;
    }

    public void setMessage(MessageHeader message) {
        this.message = message;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
    
}
